package com.augurit.common.common.http.kt.api

import com.augurit.common.common.http.kt.model.Result
import com.augurit.common.common.http.kt.request.ExtraParam
import com.augurit.common.common.http.kt.request.IPlatFormStrategy
import com.augurit.common.common.http.kt.request.Method
import java.lang.reflect.Type


/**
 *  author : yanghaozhang
 *  date : 2022/5/5 10:12
 *  description :
 */
interface TaskFactory {

    fun <OutputData> request(
        platform: IPlatFormStrategy,
        type: Type,
        method: Method,
        path: String,
        parameters: ExtraParam?,
        headers :Map<String,String>?
    ): IApiTask<String, Result<OutputData, Exception>>

    fun <Response, OutputData> request(
        platform: IPlatFormStrategy,
        serviceBlock: suspend IPlatFormStrategy.() -> Response,
        type: Type,
    ): IApiTask<Response, Result<OutputData, Exception>>

    fun <Response, OutputData> request(
        request: RequestConvertible<Response>,
        apiTransform: IApiTransform<Response, Result<OutputData, Exception>>
    ): IApiTask<Response, Result<OutputData, Exception>>



    interface Convenience : TaskFactory {
        fun <OutputData> get(
            platform: IPlatFormStrategy,
            type: Type,
            path: String,
            parameters: ExtraParam? = null,
            headers :Map<String,String>? = null,
        ): IApiTask<String, Result<OutputData, Exception>>

        fun <OutputData> post(
            platform: IPlatFormStrategy,
            type: Type,
            path: String,
            parameters: ExtraParam? = null,
            headers :Map<String,String>?= null,
        ): IApiTask<String, Result<OutputData, Exception>>
    }
}